package com.kele.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * 创作人 王箫凯
 * Date 2021/6/11
 * Time 19:47
 * 对分页进行限制
 * @author 王箫凯
 */

@Data
public class PageUtil {
    private int pageNums;
    private int pageNum;
    private int size;
    private int pageSize;
    private int start;


    public PageUtil(int pageNum, int size, int pageSize) {
        this.pageNum = pageNum;
        this.size = size;
        this.pageSize=pageSize;
        if (this.size  % this.pageSize>0){
            this.pageNums=this.size/this.pageSize +1;
        }
        else {
            this.pageNums=this.size/this.pageSize;
        }
        if (pageNum<1){
            this.pageNum=1;
        }

        if (pageNum>this.pageNums){
            this.pageNum=this.pageNums;
        }

        this.start=(this.pageNum-1)*pageSize;
    }
}
